
/*
* 修改手机下一步操作
* */
var nextPhoneDevice={
    /*android设备*/
    androidLoad:function(){
        var oldPhone=JSON.parse(AnroidWebActivity.getAuthorityState()).account;//获取当前用户的账号
        nextPhoneDevice.nextPage(oldPhone);//修改手机下一步方法调用
    },
    /*ios设备*/
    iosLoad:function(){
        baseAll.runWebViewJavascriptBridgeArr(function(data,responseCallback){
            var objData = {};
            WebViewJavascriptBridge.callHandler("getAccount", null, function (response) {
                objData.account = response; //IOS的token
                nextPhoneDevice.nextPage(objData.account);//修改手机下一步方法调用
            });
        });
    },
    /*手机更改下一步  页面跳转操作*/
    nextPage:function(oldPhone){
        AlterMobilePhone.init({
            formInput:".formInput",
            mobileText:"#mobile",//获取手机文本框
            getCodeBtn:"#get_code",//获取验证码按钮
            codeText:"#codes",//短信验证码
            nextBtn:"#next_btn",
            smsTPL:oPublic.OLD_OWNER_CHANGE_MOBILE_GPS,//短信模板编码
            model:{ //模态框
                modal:"#alterMobileModal",
                sureBtn:".sureBtn",
                cancelBtn:".closed_btn",
                codeImg:"#codeImg",//验证码图片
                imgTextBox:"#random_code"//图片随机验证码
            },
            required_register:false,
            //提交按钮判断显示
            statusSubBtn:function(formInput,mobileText,codeText,subBtn){
                $(formInput).keyup(function(){
                    var telephone=$(mobileText).val();
                    var shortCodes=$(codeText).val();
                    if(telephone.length==11&&shortCodes.length==4){
                        $(subBtn).attr("disabled",false).addClass("active_status");
                    }else{
                        $(subBtn).attr("disabled",true).removeClass("active_status");
                    }
                });
            },//进入下一步
            nextOperate:function(formInput,subBtn){
                 //window.location.href=baseAll.getUrl(window.location.href,"alterMobileSure.html");
                var self=this;
                $(subBtn).on("click",function(){
                    var flag=true;
                    $(formInput).each(function(){
                        var regStr=$(this).attr("data-reg");
                        var errorMsg=$(this).attr("data-error");
                        var reg=new RegExp(regStr);
                        var oValue=$(this).val();
                        if(reg&&!reg.test(oValue)){
                            oPublic.errorText($(this),errorMsg,"warn","dl");
                            flag=false;
                            return;
                        }
                    });
                    if(flag){
                        baseAll.addLoading();
                        $.ajax({
                            type:"get",
                            url:oPublic.basePath()+"/s/sms/msg/verify",
                            timeout:baseAll.timeout,
                            data:{
                                mobile:$(self.mobileText).val(),//手机号
                                validateCode:$(self.codeText).val(),//验证码
                                smsTplCode:self.smsTPL//短息编码
                            },
                            success:function(data){
                                if(data.opStatus==0){
                                    window.location.href=baseAll.getUrl(window.location.href,"alterMobileSure.html");
                                    localStorage.setItem("oldTelephone",$(self.mobileText).val());//旧手机号码
                                    localStorage.setItem("oldCode",$(self.codeText).val());//旧验证码
                                    baseAll.closeLoading();
                                }else{
                                    //调用弹窗  公共方法  --提示错误信息
                                    baseAll.closeLoading();
                                    baseAll.pubilcModal(data.msgDesc);
                                }
                            },
                            error:function(){
                                baseAll.closeLoading();
                                baseAll.pubilcModal('网络连接失败了...');
                            }
                        })
                    }
                });
            },
            //判断手机号码是否是用户的旧手机号码
            oldPhone:function(mobileText){
                //如果当前输入的账号与用户的真实账号不匹配，弹窗提示
                if(mobileText!==oldPhone){
                    oPublic.pubilcModal("旧手机号码不正确");
                    return false;
                }else{
                    return true;
                }
            }
        });
    }
}